import dataColor from "echarts/src/visual/dataColor";

export const transformToFile = (dataColor, name, type) => {
    return new File([data], name, {
        type,
        lastModified: Date.now()
    })
}

export const base64ToFile = (base64, fileName) => {
    let arr = base64.split(','),
        mime = arr[0].match(/:(.*?);/)[1],
        bstr = atob(arr[1]),
        n = bstr.length,
        u8arr = new Uint8Array(n)
    while (n--) {
        u8arr[n] = bstr.charCodeAt(n)
    }
    return transformToFile(u8arr, fileName, mime)
}

export const createObjectURl = data => {
    return URL.createObjectURL(data)
}